<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="搬砖 嵌入式">
<meta property="og:type" content="website">
<meta property="og:title" content="学无止境">
<meta property="og:url" content="http://example.com/page/10/index.html">
<meta property="og:site_name" content="学无止境">
<meta property="og:description" content="搬砖 嵌入式">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="xudonglei">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/page/10/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>学无止境</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">学无止境</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Do not bb, show me the example</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/05/20/PID%E7%AE%97%E6%B3%95%E4%B8%AD%E7%9A%84%E6%AF%94%E4%BE%8B%E6%8E%A7%E5%88%B6%EF%BC%8C%E7%A7%AF%E5%88%86%E6%8E%A7%E5%88%B6%EF%BC%8C%E5%BE%AE%E5%88%86%E6%8E%A7%E5%88%B6%E7%9A%84%E5%90%AB%E4%B9%89/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/05/20/PID%E7%AE%97%E6%B3%95%E4%B8%AD%E7%9A%84%E6%AF%94%E4%BE%8B%E6%8E%A7%E5%88%B6%EF%BC%8C%E7%A7%AF%E5%88%86%E6%8E%A7%E5%88%B6%EF%BC%8C%E5%BE%AE%E5%88%86%E6%8E%A7%E5%88%B6%E7%9A%84%E5%90%AB%E4%B9%89/" class="post-title-link" itemprop="url">PID算法中的比例控制，积分控制，微分控制的含义</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-05-20 20:54:31" itemprop="dateCreated datePublished" datetime="2023-05-20T20:54:31+08:00">2023-05-20</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%AE%97%E6%B3%95/" itemprop="url" rel="index"><span itemprop="name">算法</span></a>
                </span>
            </span>

          
            <span id="/2023/05/20/PID%E7%AE%97%E6%B3%95%E4%B8%AD%E7%9A%84%E6%AF%94%E4%BE%8B%E6%8E%A7%E5%88%B6%EF%BC%8C%E7%A7%AF%E5%88%86%E6%8E%A7%E5%88%B6%EF%BC%8C%E5%BE%AE%E5%88%86%E6%8E%A7%E5%88%B6%E7%9A%84%E5%90%AB%E4%B9%89/" class="post-meta-item leancloud_visitors" data-flag-title="PID算法中的比例控制，积分控制，微分控制的含义" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/05/20/PID%E7%AE%97%E6%B3%95%E4%B8%AD%E7%9A%84%E6%AF%94%E4%BE%8B%E6%8E%A7%E5%88%B6%EF%BC%8C%E7%A7%AF%E5%88%86%E6%8E%A7%E5%88%B6%EF%BC%8C%E5%BE%AE%E5%88%86%E6%8E%A7%E5%88%B6%E7%9A%84%E5%90%AB%E4%B9%89/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/05/20/PID%E7%AE%97%E6%B3%95%E4%B8%AD%E7%9A%84%E6%AF%94%E4%BE%8B%E6%8E%A7%E5%88%B6%EF%BC%8C%E7%A7%AF%E5%88%86%E6%8E%A7%E5%88%B6%EF%BC%8C%E5%BE%AE%E5%88%86%E6%8E%A7%E5%88%B6%E7%9A%84%E5%90%AB%E4%B9%89/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1xz4y187w1/?spm_id_from=333.999.0.0&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV1xz4y187w1/?spm_id_from=333.999.0.0&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<p>​        谈到PID控制器，常常会看到如下这个公式：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202305202100340.png" style="zoom:80%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202305202102642.png" style="zoom:67%;">

<p>​    现在假设有下面这个实际环境，控制直流电机的转速，我们想让电机转速达到每分钟1000转。因为PID是闭环控制，所以要把电机实际的转速采集到作为闭环的反馈。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202305202106832.png" style="zoom:80%;">

<p>​        图中这个差值600会作为PID控制器的输入。</p>
<h3 id="P控制器"><a href="#P控制器" class="headerlink" title="P控制器"></a>P控制器</h3><p>​        为了方便说明每个控制器的作用，我们先用P来控制电机看看，会出现什么现象。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202305202109370.png" style="zoom:80%;">

<p>​        下面这个是用P来控制转速得到的曲线，我们发现随着系数Kp的增加，转速曲线的波动越来越陡峭，波峰也越来越高。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202305202112720.png" style="zoom:70%;">

<p>从这里我们可以发现有两个问题，问题1存在转速波动，这个波动在实际的应用场景中往往是不可以接受的，比如控制一个电动车的速度，这种波动对于驾驶员感受很不好。问题2存在稳态误差，与目标速度总会存在偏差。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202305202117606.png" style="zoom:70%;">

<h3 id="D控制器"><a href="#D控制器" class="headerlink" title="D控制器"></a>D控制器</h3><p>​        针对问题1的转速波动，可以通过增加小D来解决。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202305202119648.png" style="zoom:70%;">

<p>​        下面我们来看下小D是如何减少波动的：当e(t)大于e(t-1)，通过小D会将转速往靠近目标值方向调整。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202305202124037.png" style="zoom:70%;">

<p>​        反之当e(t)小于e(t-1)时，说明当前速度正在靠近目标速度，通过小D公式可以知道，这个时候会把转速往原理目标转速的方向调整。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202305202129718.png" style="zoom:67%;">

<p>​        所以你会发现这里的小D就像一个阻尼器。</p>
<h3 id="I控制器"><a href="#I控制器" class="headerlink" title="I控制器"></a>I控制器</h3><p>​        针对问题2的稳态误差，可以通过增加小I来解决。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202305202134918.png" style="zoom:67%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202305202136873.png" style="zoom:57%;">

<p>当有稳态误差的时候，小I会对这段误差做正向积分，在积分作用下，小I部分的值会越来越大，从而u(t)会越来越大，转速就提高了。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202305202138890.png" style="zoom:57%;">

<p>​        <strong>当转速超过目标值时，小I会对这部分偏差进行负向积分</strong></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202305202141887.png" style="zoom:57%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/05/17/FPGA%E4%B8%AD%E8%B7%A8%E6%97%B6%E5%9F%9F%E5%AF%BC%E8%87%B4%E7%9A%84%E9%97%AE%E9%A2%98/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/05/17/FPGA%E4%B8%AD%E8%B7%A8%E6%97%B6%E5%9F%9F%E5%AF%BC%E8%87%B4%E7%9A%84%E9%97%AE%E9%A2%98/" class="post-title-link" itemprop="url">FPGA中跨时域导致的问题</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-05-17 21:59:23" itemprop="dateCreated datePublished" datetime="2023-05-17T21:59:23+08:00">2023-05-17</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/FPGA/" itemprop="url" rel="index"><span itemprop="name">FPGA</span></a>
                </span>
            </span>

          
            <span id="/2023/05/17/FPGA%E4%B8%AD%E8%B7%A8%E6%97%B6%E5%9F%9F%E5%AF%BC%E8%87%B4%E7%9A%84%E9%97%AE%E9%A2%98/" class="post-meta-item leancloud_visitors" data-flag-title="FPGA中跨时域导致的问题" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/05/17/FPGA%E4%B8%AD%E8%B7%A8%E6%97%B6%E5%9F%9F%E5%AF%BC%E8%87%B4%E7%9A%84%E9%97%AE%E9%A2%98/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/05/17/FPGA%E4%B8%AD%E8%B7%A8%E6%97%B6%E5%9F%9F%E5%AF%BC%E8%87%B4%E7%9A%84%E9%97%AE%E9%A2%98/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://www.cnblogs.com/xiaoyangerlaoshi/p/13543770.html">https://www.cnblogs.com/xiaoyangerlaoshi/p/13543770.html</a></p>
<p>​        在FPGA设计中，不太可能只用到一个时钟。因此跨时钟域的信号处理问题是我们需要经常面对的。</p>
<p>跨时钟域信号如果不处理的话会导致2个问题：</p>
<p>(1) 若高频率时钟区域输出一个脉冲信号给低频率时钟区域，则该脉冲很有可能无法被采样到，示意图如下，clk2根本采样不到pulse，</p>
<p>但是从原理上来说，低频时钟是无法完全去采样高频信号的，这里面一定会丢失信息。这是无法避免的。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202305172201595.png"></p>
<p>(2) 亚稳态问题</p>
<p>​        在说明亚稳态之前，我们需要先了解什么是建立时间和保持时间</p>
<p>​        建立时间：在时钟沿到来前，被采样信号应该提前一段时间就进入稳定状态，这个时间称为建立时间</p>
<p>​        保持时间：在时钟沿到来后，被采样的信号应该保持稳定一段时间，这个时间称为保持时间</p>
<p>​        而亚稳态就是建立时间和保持时间不满足导致的。如下图所示，就是建立时间不满足，造成dout是个不确定值，即亚稳态。</p>
<p>​        很多新人以为亚稳态仅仅是逻辑上的障碍，其实亚稳态是实实在在的电路上的问题。模拟电路中，三极管主要工作在其放大区间，而在数字电路却是要工作在截至态。亚</p>
<p>​        稳态非常类似模拟电路中的放大态，这个状态将使得器件的输出电流被放大，如果这个状态被传递，那么将导致更多的电路处在放大电路的工作状态中，这将引起巨大的</p>
<p>​        电流和功耗，甚至烧毁芯片，所以，跨时钟域是一定会出现亚稳态的，但是我们必须要把亚稳态控制在一个很小的范围内。这就是为什么要在其后面再用一个寄存器的原因。它的功能就是把亚稳态仅仅限制在那一个寄存器的小区域。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202305172202155.png"></p>
<p>​        亚稳态会造成严重的后果。就像将军发命令一样，若其发出的是一个亚稳态的命令，士兵A可能判定这个命令为进攻，士兵B可能判定这个命令为撤退，这将引起极大的混乱。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/04/20/STM32%20FSMC%E6%97%B6%E5%BA%8F/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/04/20/STM32%20FSMC%E6%97%B6%E5%BA%8F/" class="post-title-link" itemprop="url">STM32 FSMC时序</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-04-20 20:25:32" itemprop="dateCreated datePublished" datetime="2023-04-20T20:25:32+08:00">2023-04-20</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/04/20/STM32%20FSMC%E6%97%B6%E5%BA%8F/" class="post-meta-item leancloud_visitors" data-flag-title="STM32 FSMC时序" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/04/20/STM32%20FSMC%E6%97%B6%E5%BA%8F/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/04/20/STM32%20FSMC%E6%97%B6%E5%BA%8F/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://blog.csdn.net/Mr_Fuuuuuu/article/details/109743381?spm=1001.2101.3001.6650.10&amp;utm_medium=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-10-109743381-blog-106328611.235%5Ev29%5Epc_relevant_default_base3&amp;depth_1-utm_source=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-10-109743381-blog-106328611.235%5Ev29%5Epc_relevant_default_base3&amp;utm_relevant_index=16">https://blog.csdn.net/Mr_Fuuuuuu/article/details/109743381?spm=1001.2101.3001.6650.10&amp;utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-10-109743381-blog-106328611.235%5Ev29%5Epc_relevant_default_base3&amp;depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-10-109743381-blog-106328611.235%5Ev29%5Epc_relevant_default_base3&amp;utm_relevant_index=16</a></p>
<h3 id="一、FSMC读时序（FSMC输入）"><a href="#一、FSMC读时序（FSMC输入）" class="headerlink" title="一、FSMC读时序（FSMC输入）"></a>一、FSMC读时序（FSMC输入）</h3><p>​        下图是STM32的FSMC读时序，最重要的是RD非信号，也就是读使能信号。图中的红色箭头，可以理解为两信号之间有关联，然后中间存在一个时延，而这个时延可以通过编程来设置，从而匹配不同速度的外设；时钟信号可以忽略，我画上去只是便于理解，上升沿触发也是我假设的，实际情况不得而知。</p>
<p>​        FSMC先送出地址和其他控制信号，然后经（ADDSET+1）个HCLK时钟后，RD非信号发生负跳变，再经（DATASET+1）个HCLK时钟后，此时FSMC从数据总线上读入数据（我们要保证外设在此时刻之前将数据送上数据总线，这样FMC才能读入有效的数据），再经2个HCLK时钟后，RD非信号变为高电平。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202304202028091.png" style="zoom:80%;">

<h3 id="二、FSMC写时序（FSMC输出）"><a href="#二、FSMC写时序（FSMC输出）" class="headerlink" title="二、FSMC写时序（FSMC输出）"></a>二、FSMC写时序（FSMC输出）<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202304202030433.png" style="zoom:70%;"></h3><p>​        与读操作同理，配置FSMC读写操作用的相同的时序。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/04/20/hex%E6%96%87%E4%BB%B6%E4%BB%8B%E7%BB%8D%E5%8F%8A%E4%BD%BF%E7%94%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/04/20/hex%E6%96%87%E4%BB%B6%E4%BB%8B%E7%BB%8D%E5%8F%8A%E4%BD%BF%E7%94%A8/" class="post-title-link" itemprop="url">hex文件介绍及使用</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-04-20 13:38:48" itemprop="dateCreated datePublished" datetime="2023-04-20T13:38:48+08:00">2023-04-20</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/04/20/hex%E6%96%87%E4%BB%B6%E4%BB%8B%E7%BB%8D%E5%8F%8A%E4%BD%BF%E7%94%A8/" class="post-meta-item leancloud_visitors" data-flag-title="hex文件介绍及使用" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/04/20/hex%E6%96%87%E4%BB%B6%E4%BB%8B%E7%BB%8D%E5%8F%8A%E4%BD%BF%E7%94%A8/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/04/20/hex%E6%96%87%E4%BB%B6%E4%BB%8B%E7%BB%8D%E5%8F%8A%E4%BD%BF%E7%94%A8/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://icspec.com/news/article-details/2113863">https://icspec.com/news/article-details/2113863</a></p>
<h3 id="1、什么是hex文件"><a href="#1、什么是hex文件" class="headerlink" title="1、什么是hex文件"></a>1、什么是hex文件</h3><p>​        以*.hex为后缀的文件我们称之为HEX文件。hex是intel规定的标准，hex的全称是Intel HEX，此类文件通常用于传输将被存于ROM或EEPROM中的程序和数据。是由一行行符合Intel HEX文件格式的文本所构成的ASCII文本文件。<br>​        HEX的英语原始意思是16进制。这种文件格式主要用于保存单片机固件。整个文件以行为单位，每行以冒号开头，内容全部为16进制码，2个ASCII码字符表示1个Hex字节</p>
<h3 id="2、hex文件格式"><a href="#2、hex文件格式" class="headerlink" title="2、hex文件格式"></a>2、hex文件格式</h3><p>​        先上图：用Notepad++ 直接打开的一个32bit的单片机编译器编译的一个hex文件(中间省略了部分)：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/684f15a9-28ae-382a-9b8e-9ecbdae261e5.png" style="zoom:80%;">

<p>​        通过上面的文件，我们不难发现，hex文件每行都由一个冒号:作为起始码。<br>​        每行都符合以下图示的格式：（注意：下图中一格代表一个ASC码，用一个字节表示）</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/a57273c2-9072-32cb-8000-605824c225fc.png" style="zoom:80%;">

<p>​        <strong>起始码</strong>：每行数据作为一帧，并由:作为起始码；<br>​        <strong>字节长度</strong>：两个十六进制数字（一对十六进制数字），指示数据字段中的字节数（十六进制数字对）。最大字节数为255（0xFF）。16（0x10）和32（0x20）是常用的字节数；</p>
<p>​        <strong>地址</strong>：四个十六进制数字，代表数据的16位起始存储器地址偏移量。数据的物理地址是通过将此偏移量添加到先前建立的基地址来计算的，因此允许内存寻址超过16位地址的64 KB限制。基地址默认为零，可以通过各种类型的记录进行更改。基地址和地址偏移量始终表示为大端值。</p>
<p>​        <strong>指令类型</strong>：两个十六进制数字00到05，定义了这行数据的具体含义；        </p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/b01324c0-5d0e-3c5c-96a6-44812e07bfed.png" style="zoom:80%;">

<p>​        <strong>校验码</strong>：（两个十六进制数字），可以用来验证记录没有错误的计算值；数据：n字节数据序列，由2个n十六进制数字表示；注意校验和算法：累加和=校验码之前所有16进制，校验和=0x100-累加和。            </p>
<p>​        如之前的hex文件图</p>
<p><strong>第一行</strong>020000040804EE中，可以看做是0x02 0x00 0x00 0x04 0x08 0x04 0xEE，<br>02：代表本行有2个字节数据<br>0000：表示偏移地址或无用填0<br>04：扩展线性地址标识，表面后面2个字节数据是后面数据的基地址<br>注：由于每行标识数据地址的只有2Byte，所以最大只能到64K，为了可以保存高地址的数据，故有了扩展线性地址记录也叫作32位地址记录或HEX386记录.这些记录含数据的高16位，扩展线性地址记录总是有两个数据字节。<br>0804：是扩展地址 (0x0804 &lt;&lt; 16) = 0x08040000后面的数据记录都以这个地址为基地址。<br>EE: 记录本行校验和 EE=0x100-(0x02+0x04+0x08+0x04)</p>
<p><strong>第二行</strong>也按格式切分开为 10 0000 00 A8990020C1010408830B040839080408 DA<br>10：本行有0x10个Byte数据（即16个Byte数据）<br>0000：表示本行数据起始地址为0x08040000。下一行则是0x08040010依次类推<br>00：数据类型，表示后面字节为记录的数据<br>A8990020C1010408830B040839080408：16个byte的数据<br>DA: 校验和<br>00类型的行都大差不差，只是地址和数据不同而已，就不多赘述，以此类推即可。</p>
<p><strong>倒数第二行</strong>也按格式切分开为 04 0000 05 080401AD 3D<br>04：表示本行有4个Byte数据<br>0000：无用填0<br>05：数据类型，表示开始线性地址记录<br>080401AD：表示要执行的下一个指令的地址（main函数地址）<br>3D：校验和</p>
<p>位置只有四个数据，但是 标注类型是 05, 即他是一个 “开始线性地址记录”。<br>说那么多，什么是开始线性地址记录呢？其实他就是函数入口地址<br>例如在该工程的 .map 文件中可以看到以下信息</p>
<p>Memory Map of the image</p>
<p>Image Entry point : 0x080401AD<br>…<br>但该行对于普通的MCU烧写程序来说没有什么作用，参考以下资料：<br>05 类型：Start Linear Address Record. The address field is 0000, the byte count is 04. The 4 data<br>bytes represent the 32-bit value loaded into the EIP register of the 80386 and higher CPU.</p>
<p><strong>最后一行</strong> 00000001FF<br>00：代表本行有0个字节数据<br>0000：无用填0<br>01：标识hex文件结束<br>FF：校验和<br>注：每一个hex文件都以这个结尾。</p>
<h3 id="3、hex文件合并"><a href="#3、hex文件合并" class="headerlink" title="3、hex文件合并"></a>3、hex文件合并</h3><p>​        打开我们的hex文件，就以BOOT和APP代码为例，用记事本或者其他的软件（notepad++等）打开</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230420134853.png" style="zoom:80%;">

<p>​        hex文件最后一行是代表文件的结束，那么我们只需要删除boot文件的最后一行代码，然后把APP的代码的全部内容直接拷贝过来，接到boot文件的最后一行。保存后我们就得到了最终的hex文件，直接烧录进去MCU即可。</p>
<h3 id="4、尝试往flash某个地址添加数据"><a href="#4、尝试往flash某个地址添加数据" class="headerlink" title="4、尝试往flash某个地址添加数据"></a>4、尝试往flash某个地址添加数据</h3><p>​        现在有一个需求，需要往0x01 E000地址写入4个字节：0x00000001</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/flash位置处.png" style="zoom:80%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230420135356.png" style="zoom:80%;">

<p>3238行和3239行就是我自己新添加的。</p>
<p>3238行指令类型为04，表示0x0001&lt;&lt;16，后面的数据记录都以这个地址为基地址</p>
<p>3239行指令类型为00，偏移地址为0xE000，写入的数据在flash中从低地址到高地址分别为：0x01，0x00，0x00，0x00。</p>
<p>C语言程序中写入的数据为：0x00000001。</p>
<h3 id="5、技巧"><a href="#5、技巧" class="headerlink" title="5、技巧"></a>5、技巧</h3><p>​        正常情况下，校验码都是正确的，校验码部分会显示绿色</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230420142312.png" style="zoom:80%;">

<p>​        如果有校验码出错，Notepad++会显示成非绿色</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230420142450.png" style="zoom:80%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/04/15/template%20typename%20T/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/04/15/template%20typename%20T/" class="post-title-link" itemprop="url">template typename T</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-04-15 21:24:39" itemprop="dateCreated datePublished" datetime="2023-04-15T21:24:39+08:00">2023-04-15</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/" itemprop="url" rel="index"><span itemprop="name">编程语言</span></a>
                </span>
            </span>

          
            <span id="/2023/04/15/template%20typename%20T/" class="post-meta-item leancloud_visitors" data-flag-title="template typename T" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/04/15/template%20typename%20T/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/04/15/template%20typename%20T/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://www.cnblogs.com/cs1003/archive/2012/08/22/2651175.html">https://www.cnblogs.com/cs1003/archive/2012/08/22/2651175.html</a></p>
<p>​        其实就是这个东西可以根据你所需要的类型就行匹配。其实就是模板</p>
<p>​        比如求最小值，要int，double，char，那么你就 要写三个函数</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">sum</span><span class="params">(<span class="keyword">int</span>, <span class="keyword">int</span>)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">float</span> <span class="title">sum</span><span class="params">(<span class="keyword">float</span>, <span class="keyword">float</span>)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">double</span> <span class="title">sum</span><span class="params">(<span class="keyword">double</span>, <span class="keyword">double</span>)</span></span>;</span><br></pre></td></tr></table></figure>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">但是有了templae &lt;<span class="keyword">typename</span> T&gt;, 你就只需要写一个函数。</span><br></pre></td></tr></table></figure>
<p>​        详见代码：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;vector&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</span><br><span class="line"><span class="function">T <span class="title">mmax</span><span class="params">(T a,T b)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">return</span> a&gt;b?a:b;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">int</span>  a,b;</span><br><span class="line">    <span class="built_in">cin</span>&gt;&gt;a&gt;&gt;b;</span><br><span class="line">    <span class="built_in">cout</span>&lt;&lt;mmax(a,b)&lt;&lt;<span class="built_in">endl</span>;</span><br><span class="line">    <span class="keyword">char</span> c,d;</span><br><span class="line">    <span class="built_in">cin</span>&gt;&gt;c&gt;&gt;d;</span><br><span class="line">    <span class="built_in">cout</span>&lt;&lt;mmax(c,d)&lt;&lt;<span class="built_in">endl</span>;</span><br><span class="line">    <span class="keyword">double</span> f,g;</span><br><span class="line">    <span class="built_in">cin</span>&gt;&gt;f&gt;&gt;g;</span><br><span class="line">    <span class="built_in">cout</span>&lt;&lt;mmax(f,g)&lt;&lt;<span class="built_in">endl</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/04/15/Verilog%E7%9A%84inout%E8%AF%AD%E5%8F%A5/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/04/15/Verilog%E7%9A%84inout%E8%AF%AD%E5%8F%A5/" class="post-title-link" itemprop="url">Verilog的inout语句</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-04-15 07:22:38" itemprop="dateCreated datePublished" datetime="2023-04-15T07:22:38+08:00">2023-04-15</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/FPGA/" itemprop="url" rel="index"><span itemprop="name">FPGA</span></a>
                </span>
            </span>

          
            <span id="/2023/04/15/Verilog%E7%9A%84inout%E8%AF%AD%E5%8F%A5/" class="post-meta-item leancloud_visitors" data-flag-title="Verilog的inout语句" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/04/15/Verilog%E7%9A%84inout%E8%AF%AD%E5%8F%A5/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/04/15/Verilog%E7%9A%84inout%E8%AF%AD%E5%8F%A5/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV12b411d76Z/?spm_id_from=333.337.search-card.all.click&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8">https://www.bilibili.com/video/BV12b411d76Z/?spm_id_from=333.337.search-card.all.click&amp;vd_source=2ef3411e1c045a25cc2351abaa2c3ce8</a></p>
<p>​        <img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202304150722991.png" style="zoom:53%;"></p>
<p>​        inout从字面上就知道是输入和输出的意思，也就是说用inout定义的信号，即可以当输入又可以当输出，但这个不是在同一个时间点。</p>
<p>​        图中c其实就是inout端，当oe有效的时候，三态门就正常的输出了，a这个信号就通过这个三态门之后，就会输出到c这个信号上，此时c实际上就是一个输出端。这个时候图中c也可以通过一根线输入到b这个信号，在这个情况下，实际上a，c，b这三个点的信号值是一样的。这个时候就是输出的状态。</p>
<p>​        当是输入的时候，oe这个信号等于0，这个三态门实际上就被截止了，三态门的这个输出端c实际上是没有驱动的。换言之c这一个点的信号它就交由外部信号来驱动了，这个时候外部的这个信号给出的值就能驱动c这个点，也就能引到了b这个输入端，这个时候c作为的是输入信号来使用的。</p>
<p><strong>补充：</strong></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202304150826670.png" style="zoom:80%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/04/14/PCIe%E8%BD%AC%E4%B8%B2%E5%8F%A3Linux%E9%A9%B1%E5%8A%A8%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/04/14/PCIe%E8%BD%AC%E4%B8%B2%E5%8F%A3Linux%E9%A9%B1%E5%8A%A8%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E/" class="post-title-link" itemprop="url">PCIe转串口Linux驱动使用说明</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-04-14 20:58:10" itemprop="dateCreated datePublished" datetime="2023-04-14T20:58:10+08:00">2023-04-14</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Linux/" itemprop="url" rel="index"><span itemprop="name">Linux</span></a>
                </span>
            </span>

          
            <span id="/2023/04/14/PCIe%E8%BD%AC%E4%B8%B2%E5%8F%A3Linux%E9%A9%B1%E5%8A%A8%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E/" class="post-meta-item leancloud_visitors" data-flag-title="PCIe转串口Linux驱动使用说明" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/04/14/PCIe%E8%BD%AC%E4%B8%B2%E5%8F%A3Linux%E9%A9%B1%E5%8A%A8%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/04/14/PCIe%E8%BD%AC%E4%B8%B2%E5%8F%A3Linux%E9%A9%B1%E5%8A%A8%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        原文地址：<a target="_blank" rel="noopener" href="https://blog.csdn.net/WCH_TechGroup/article/details/124803364">https://blog.csdn.net/WCH_TechGroup/article/details/124803364</a></p>
<p>​        PCIe转串口芯片CH382/CH384以及PCI转串口芯片CH351/CH352/CH353/CH355/CH356/CH357/CH358/CH359以及使用如上芯片外加CH432/CH438的组合串口转接方案均支持Windows和Linux操作系统，在系统下会生成多个独立的串口，各虚拟串口分别对应一个硬件串口。各串口独立工作，互不影响。本文主要介绍Linux操作系统如何为设备加载厂商串口驱动。</p>
<p>​        厂商驱动下载链接： <a target="_blank" rel="noopener" href="http://www.wch.cn/downloads/CH38XDRV_ZIP.html">http://www.wch.cn/downloads/CH38XDRV_ZIP.html</a></p>
<p>​        厂商驱动Github链接：<a target="_blank" rel="noopener" href="https://github.com/WCHSoftGroup/ch35_38x_linux">https://github.com/WCHSoftGroup/ch35_38x_linux</a></p>
<h3 id="步骤一：解绑系统内置串口驱动"><a href="#步骤一：解绑系统内置串口驱动" class="headerlink" title="步骤一：解绑系统内置串口驱动"></a>步骤一：解绑系统内置串口驱动</h3><h4 id="确定串口卡状态"><a href="#确定串口卡状态" class="headerlink" title="确定串口卡状态"></a>确定串口卡状态</h4><p>​        Linux内核中，系统启动时会自动加载内置的8250_pci驱动。该驱动包含各厂家PCI/PCIe产品，可以通过lspci命令确认当前硬件的工作状态以及驱动匹配情况。CH35x和CH38x芯片使用的VID有2种：0x1C00和0x4348，命令为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">lspci -vd 1c00:*</span><br><span class="line">lspci -vd 13a8:*</span><br></pre></td></tr></table></figure>
<p>​        运行如上命令后，若设备存在，则会显示如下设备信息：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">07:00.0 Serial controller: Device 1c00:3470 (rev 10) (prog-if 05 [16850])</span><br><span class="line">Subsystem: Device 1c00:3470</span><br><span class="line">Flags: fast devsel, IRQ 41</span><br><span class="line">I/O ports at 1000 [size=256]</span><br><span class="line">Memory at 58700000 (32-bit, prefetchable) [size=32K]</span><br><span class="line">I/O ports at 1100 [size=4]</span><br><span class="line">Expansion ROM at 58700000 [size=32K]</span><br><span class="line">Capabilities: [60] Power Management version 3</span><br><span class="line">Capabilities: [68] MSI: Enable- Count=1/32 Maskable+ 64bit+</span><br><span class="line">Capabilities: [80] Express Legacy Endpoint, MSI 00</span><br><span class="line">Capabilities: [100] Advanced Error Reporting</span><br><span class="line">Kernel driver in use: serial</span><br><span class="line">Kernel modules: 8250_pci</span><br></pre></td></tr></table></figure>
<p>​        如上所示，在“Kernel modules”信息中会显示当前已经为该设备加载的驱动。注：系统内置的可以满足设备基础串口通信的需求，该驱动为串口卡创建的设备名称为：/dev/ttySn，也可以通过dmesg | grep ttyS 通过对比ttyS的IO地址和lspci的地址来确定具体的ttyS通道。</p>
<p>​        如果需要使用扩展功能，如：支持串口高波特率通讯，开启半双工功能支持RS485串口通讯等，则务必使用厂商单独提供的串口驱动。</p>
<h4 id="解绑本地8250-pci串口驱动"><a href="#解绑本地8250-pci串口驱动" class="headerlink" title="解绑本地8250_pci串口驱动"></a>解绑本地8250_pci串口驱动</h4><p>​        执行如下命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ls /sys/bus/pci/drivers/serial</span><br></pre></td></tr></table></figure>
<p>​        如上命令返回内容如下所示：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">0000:07:00.0 bind new_id remove_id uevent unbind</span><br></pre></td></tr></table></figure>
<p>​        使用如下命令完成驱动和设备的解绑：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">echo -n “0000:07:00.0” &gt; /sys/bus/pci/drivers/serial/unbind</span><br></pre></td></tr></table></figure>
<h3 id="步骤二：加载厂商串口驱动"><a href="#步骤二：加载厂商串口驱动" class="headerlink" title="步骤二：加载厂商串口驱动"></a>步骤二：加载厂商串口驱动</h3><p>1、从开头的链接地址下载驱动到本地，也可以通过git clone。</p>
<p>2、参考驱动文件夹中的README.md文档完成驱动的编译和移植工作。</p>
<p>3、设备存在且工作正常的情况下，驱动会为设备生成名称为“/dev/ttyWCH”开头的串口节点。</p>
<p>若驱动加载时出错，可能原因有：</p>
<p>1、系统当前未发现任何CH35x和CH38x串口卡。</p>
<p>2、系统默认为CH35x和CH38x串口卡分配的IO地址不可用，导致驱动无法成功访问硬件，甚至造成系统Crash。原因：CH35x和CH38x串口卡的相关串口寄存器均位于IO空间内，部分非X86和X64的架构不支持独立编址或者支持分配地址但地址无法通过原生IO地址操作直接访问，此时可联系相应CPU或系统厂商咨询解决方法。</p>
<p>3、若使用CH35x和CH38x与CH43x的组合芯片方案，当主芯片和CH43x的硬件通讯异常，驱动加载也会报错，此时可以更换其他系统平台进行验证以排除原因2的问题。若其他系统上如Windows可以正常工作，则硬件正常，仅检查原因2即可。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/04/02/%E6%A0%91%E8%8E%93%E6%B4%BECM4%20eMMC%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/04/02/%E6%A0%91%E8%8E%93%E6%B4%BECM4%20eMMC%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99/" class="post-title-link" itemprop="url">树莓派CM4 eMMC系统烧写</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-04-02 13:16:58" itemprop="dateCreated datePublished" datetime="2023-04-02T13:16:58+08:00">2023-04-02</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/04/02/%E6%A0%91%E8%8E%93%E6%B4%BECM4%20eMMC%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99/" class="post-meta-item leancloud_visitors" data-flag-title="树莓派CM4 eMMC系统烧写" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/04/02/%E6%A0%91%E8%8E%93%E6%B4%BECM4%20eMMC%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/04/02/%E6%A0%91%E8%8E%93%E6%B4%BECM4%20eMMC%E7%B3%BB%E7%BB%9F%E7%83%A7%E5%86%99/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        参考原文：<a target="_blank" rel="noopener" href="https://www.waveshare.net/wiki/CM4_Burn_EMMC">https://www.waveshare.net/wiki/CM4_Burn_EMMC</a></p>
<p>树莓派CM4模块从系统安装差异上分两种，标准版本带eMMC，另一版本CM4 Lite不带eMMC。本次使用的是带eMMC的版本，并且是在Windows系统下操作的，CM4和底座如下图所示：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/95b7957fdfe3fefe7c0aaa6d1298ca8a.jpeg" style="zoom:53%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/bc603d98f82c492ba67db70f3587a793.png" style="zoom:23%;">

<h3 id="镜像下载"><a href="#镜像下载" class="headerlink" title="镜像下载"></a>镜像下载</h3><p>​        下载系统<a target="_blank" rel="noopener" href="https://www.raspberrypi.org/downloads/raspberry-pi-os/">（戳我下载）</a>，带有桌面和推荐软件的镜像(Raspberry Pi OS with desktop and recommended software)，建议EMMC 16G 或者CM4 lite 16G内存卡以上的储存空间使用。</p>
<h3 id="rpiboot（引导加载程序）下载"><a href="#rpiboot（引导加载程序）下载" class="headerlink" title="rpiboot（引导加载程序）下载"></a>rpiboot（引导加载程序）下载</h3><p>​        下载并以管理员权限打开软件rpiboot软件<a target="_blank" rel="noopener" href="https://www.waveshare.net/w/upload/f/f3/Rpiboot_setup.zip">（ 戳我下载)</a>，安装成功之后在安装目录下有一个rpiboot.exe的应用。</p>
<h3 id="进入烧录模式"><a href="#进入烧录模式" class="headerlink" title="进入烧录模式"></a>进入烧录模式</h3><p>​        断电情况下，短接底板J2上的nRPI_BOOT，如图</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230402132515.png" style="zoom:80%;">

<p>​        先通过Micro USB /Type C 接口（SLAVE 接口） 转USB接口 连接电脑，再连接电源。此时连接电脑并且给主板供电，电脑设备管理器中会识别出一个BCMxxx的设备。</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/CM4_Burn_EMMC_4.png"></p>
<p>​        然后运行rpiboot：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230402132737.png" style="zoom:50%;">

<p>开发板上的eMMC会被识别为一个可移动磁盘。</p>
<h3 id="格式化EMMC"><a href="#格式化EMMC" class="headerlink" title="格式化EMMC"></a>格式化EMMC</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230402132906.png" style="zoom:50%;">

<h3 id="烧写镜像"><a href="#烧写镜像" class="headerlink" title="烧写镜像"></a>烧写镜像</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230402133022.png" style="zoom:57%;">

<h3 id="烧录完成并重启"><a href="#烧录完成并重启" class="headerlink" title="烧录完成并重启"></a>烧录完成并重启</h3><p>​        烧录完毕断开电源，断开和电脑的连接线，将BOOT断开，重新上电即可。</p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/04/01/%E6%A0%91%E8%8E%93%E6%B4%BE%E5%86%85%E6%A0%B8%E7%BC%96%E8%AF%91/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/04/01/%E6%A0%91%E8%8E%93%E6%B4%BE%E5%86%85%E6%A0%B8%E7%BC%96%E8%AF%91/" class="post-title-link" itemprop="url">树莓派内核编译</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-04-01 12:28:18" itemprop="dateCreated datePublished" datetime="2023-04-01T12:28:18+08:00">2023-04-01</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">嵌入式</span></a>
                </span>
            </span>

          
            <span id="/2023/04/01/%E6%A0%91%E8%8E%93%E6%B4%BE%E5%86%85%E6%A0%B8%E7%BC%96%E8%AF%91/" class="post-meta-item leancloud_visitors" data-flag-title="树莓派内核编译" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/04/01/%E6%A0%91%E8%8E%93%E6%B4%BE%E5%86%85%E6%A0%B8%E7%BC%96%E8%AF%91/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/04/01/%E6%A0%91%E8%8E%93%E6%B4%BE%E5%86%85%E6%A0%B8%E7%BC%96%E8%AF%91/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        参考原文：<a target="_blank" rel="noopener" href="https://www.raspberrypi.com/documentation/computers/linux_kernel.html#cross-compiling-the-kernel">https://www.raspberrypi.com/documentation/computers/linux_kernel.html#cross-compiling-the-kernel</a></p>
<p><strong>1、下载内核源码：</strong></p>
<p>链接：<a target="_blank" rel="noopener" href="https://github.com/raspberrypi/linux">https://github.com/raspberrypi/linux</a></p>
<p>查看当前树莓派的内核版本：uname -a</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信图片_20230331212502.jpg" style="zoom:25%;">

<p>我们接下来要到官网上下载一个版本比较接近的，否则可能不太兼容</p>
<p><strong>2、登录官网，下载镜像</strong></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/微信截图_20230331212710.png" style="zoom:67%;">

<p><strong>3、交叉编译工具链下载安装</strong></p>
<p>​        先安装依赖包：sudo apt install git bc bison flex libssl-dev make libc6-dev libncurses5-dev</p>
<p>​        再安装交叉编译工具链：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202304011111484.png" style="zoom:80%;">

<p><strong>4.源码配置</strong></p>
<p>​        驱动代码的编译需要一个提前编译好的内核，所以就需要进行内核的编译，编译内核就必须完成相关的配置，配置的最终目的是会生成 .config文件，该文件是指导Makefile去把有用东西组织成内核。</p>
<p>​        配置的方法有三种：</p>
<p>​        第一种：通常买了开发板厂家会配linux内核的源码，使用厂家的.config文件进行配置</p>
<p>​        第二种：make menuconfig 一项项的进行配置，通常是基于厂家的config来配置。</p>
<p>​        第三种：全靠自己来实现。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202304011118857.png" style="zoom:80%;">

<p><strong>5.编译源码</strong></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202304011226405.png" style="zoom:80%;">
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2023/03/28/RM500U-CN%E6%A8%A1%E5%9D%97window%E5%B9%B3%E5%8F%B0%E4%BD%BF%E7%94%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="xudonglei">
      <meta itemprop="description" content="搬砖 嵌入式">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="学无止境">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2023/03/28/RM500U-CN%E6%A8%A1%E5%9D%97window%E5%B9%B3%E5%8F%B0%E4%BD%BF%E7%94%A8/" class="post-title-link" itemprop="url">RM500U-CN模块window平台使用</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-03-28 21:43:07" itemprop="dateCreated datePublished" datetime="2023-03-28T21:43:07+08:00">2023-03-28</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E7%A1%AC%E4%BB%B6/" itemprop="url" rel="index"><span itemprop="name">硬件</span></a>
                </span>
            </span>

          
            <span id="/2023/03/28/RM500U-CN%E6%A8%A1%E5%9D%97window%E5%B9%B3%E5%8F%B0%E4%BD%BF%E7%94%A8/" class="post-meta-item leancloud_visitors" data-flag-title="RM500U-CN模块window平台使用" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2023/03/28/RM500U-CN%E6%A8%A1%E5%9D%97window%E5%B9%B3%E5%8F%B0%E4%BD%BF%E7%94%A8/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2023/03/28/RM500U-CN%E6%A8%A1%E5%9D%97window%E5%B9%B3%E5%8F%B0%E4%BD%BF%E7%94%A8/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>​        <img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202303282150009.jpg" style="zoom:20%;"></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202303282150113.png" style="zoom:70%;">

<h3 id="一、驱动安装"><a href="#一、驱动安装" class="headerlink" title="一、驱动安装"></a>一、驱动安装</h3><p>​        通过usb3.0数据线接RM500U-CN 5G到电脑后，其它设备出现一系列未安装驱动的设备：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202303282153700.png" style="zoom:70%;">

<p>​        进入文件夹：Quectel_Windows_USB_Driver(U)_For_ECM_RNDIS_V1.0.13_Beta0314，点击setup.exe安装驱动，完成安装后，设备管理器会生成如下设备：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202303282158803.png" style="zoom:67%;">

<h3 id="二、用AT指令来配置"><a href="#二、用AT指令来配置" class="headerlink" title="二、用AT指令来配置"></a>二、用AT指令来配置</h3><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202303282201616.png" style="zoom:80%;">

<p>​        参考QUECTEL RM50X模组RNDIS拨号上网步骤如下：</p>
<p>​        AT+CPIN?<br>​        AT+QCFG=”usbnet”,3<br>​        AT+QNETDEVCTL=2,3,1<br>​        AT+CFUN=1,1</p>
<p>​        观察设备管理器发现多出一些无法识别的设备，比如 RNDIS （带叹号）：<br>​        右键点击RNDIS，搜索设备软件提示窗口，选择“浏览我的计算机”。选择从设备列表中选择“网络适配器”。<br>​        在网络适配器窗口的制造商列表中选择Microsoft Corporation，然后右侧列表中选择“Remote NDIS Compatible Device”即远端NDIS兼容设备。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202303282206131.png" style="zoom:67%;">

<h3 id="三、网卡拨号"><a href="#三、网卡拨号" class="headerlink" title="三、网卡拨号"></a>三、网卡拨号</h3><p>​        RG500U-CN 和 RM500U-CN 模块支持 <strong>USB 网卡拨号</strong>和 <strong>Ethernet 网卡拨号</strong>，两种网卡对应的拨号方式和拨号模式是相同的。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202303282208730.png" style="zoom:50%;">

<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202303282212458.png"></p>
<h4 id="3-1-配置-USB网卡"><a href="#3-1-配置-USB网卡" class="headerlink" title="3.1 配置 USB网卡"></a>3.1 配置 USB网卡</h4><h5 id="3-1-1-配置网卡拨号方式及驱动类型"><a href="#3-1-1-配置网卡拨号方式及驱动类型" class="headerlink" title="3.1.1 配置网卡拨号方式及驱动类型"></a>3.1.1 配置网卡拨号方式及驱动类型</h5><p>​        执行 AT+QCFG=”usbnet”,3 配置网卡拨号方式及驱动类型为 RNDIS；</p>
<p><img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202303282214694.png"></p>
<h5 id="3-1-2-配置拨号模式"><a href="#3-1-2-配置拨号模式" class="headerlink" title="3.1.2 配置拨号模式"></a>3.1.2 配置拨号模式</h5><p>​        执行 AT+QCFG=”nat”,0 配置拨号模式为网卡模式；<br>​        或者执行 AT+QCFG=”nat”,1 配置拨号模式为路由模式；<br>​        或者执行 AT+QCFG=”nat”,2 配置拨号模式为网桥模式。</p>
<h4 id="3-2-配置Ethernet网卡"><a href="#3-2-配置Ethernet网卡" class="headerlink" title="3.2 配置Ethernet网卡"></a>3.2 配置Ethernet网卡</h4><p>​        RG500U-CN 和 RM500U-CN 模块支持通过 AT 命令开启或关闭 Ethernet 网卡，且默认开启。</p>
<p>​        执行 <strong>AT+QCFG=”ethernet”,1</strong> 开启 Ethernet 网卡；</p>
<p>​        或者执行 <strong>AT+QCFG=”ethernet”,0</strong> 关闭 Ethernet 网卡。</p>
<h4 id="3-3-拨号结果"><a href="#3-3-拨号结果" class="headerlink" title="3.3 拨号结果"></a>3.3 拨号结果</h4><p>​        拨号成功以后，上位机创建相应的网卡，可通过查看网卡的状态获取拨号结果。</p>
<h3 id="四、使用过程中的一些情况"><a href="#四、使用过程中的一些情况" class="headerlink" title="四、使用过程中的一些情况"></a>四、使用过程中的一些情况</h3><p><strong>情况一：</strong></p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202303282233121.png" style="zoom:50%;">

<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202303282233487.png" style="zoom:67%;">

<p>执行 AT+QCFG=”ethernet”,1 开启 Ethernet 网卡，然后可以上网了：</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202303282240904.png" style="zoom:67%;">

<p><strong>情况二：</strong></p>
<p>​        在情况一的基础上，拔掉网线，只连接usb线，会出现一个RNDIS网卡，但是显示已经拔出，无法上网。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202303282244953.png" style="zoom:80%;">

<p>​        执行 AT+QCFG=”ethernet”,0  关闭Ethernet 网卡，这样用以太网6就可以上网了。</p>
<img src="https://xdl-blog-picture.oss-cn-shanghai.aliyuncs.com/img/202303282251860.png" style="zoom:80%;">

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/9/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/9/">9</a><span class="page-number current">10</span><a class="page-number" href="/page/11/">11</a><span class="space">&hellip;</span><a class="page-number" href="/page/29/">29</a><a class="extend next" rel="next" href="/page/11/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">xudonglei</p>
  <div class="site-description" itemprop="description">搬砖 嵌入式</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">283</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">67</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">xudonglei</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'BT0Qw9HcTpPv1a6cT1iDBXKz-gzGzoHsz',
      appKey     : 'LMCMh8v02JTMFAwKNRcgoizI',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
